package com.lxlg.lxlg_order.consumer;


import com.lxlg.lxlg_order.service.service.SeckillOrderService;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@RocketMQMessageListener(consumerGroup = "seckillorder_cancle",topic = "seckillorder_cancle")
public class CancleSeckillOrder implements RocketMQListener<String>, RocketMQPushConsumerLifecycleListener {
    @Resource
    private SeckillOrderService seckillOrderService;

    @Override
    public void onMessage(String message) {

        seckillOrderService.cancleSeckillOrder(message);
    }

    @Override
    public void prepareStart(DefaultMQPushConsumer consumer) {
        //设置重试次数
        consumer.setMaxReconsumeTimes(1);
    }
}
